home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / VIDEO.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  17KB  |  400 lines

  1. ;«RM82»«TS8,16,24,32,40,48,56,64»
  2. ; Updated 11/20/90
  3.  
  4. ;=======================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;                   All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;-----------------------------------------------------------------------
  12. ; Function prototype in QBASIC
  13. ; DECLARE FUNCTION VideoStat% ()
  14. ;
  15. ; VideoStatus Analyzer
  16. ; Program returns video information for use by QBASIC
  17. ; returns highest level of SCREEN mode supported by the Hardware.
  18. ; Returns information about the PRIMARY display only
  19. ; This routine with a select case, can tell you how many display pages
  20. ; are available in text mode, SCREEN 0:
  21. ; VGA has 8 pages
  22. ; EGA with > 64kb has 8 pages
  23. ; EGA with 64kb has 4 pages
  24. ; CGA has 4 pages
  25. ; MONO has 1 pages
  26. ; HERC has 1 page in SCREEN 0, 2 pages in SCREEN 3
  27. ;
  28. ; Exceptions:
  29. ; MCGA color returns a mode 11, so can contrast w/ VGA
  30. ; HERC w/o MSHERC.COM reports a -3 so you can tell user to correct matters
  31. ; COMPAQ with CGA reports -2 so can force use of monchrome attributes.
  32. ; EGA's with CGA diplays report -8 if have only 64kb of memory
  33. ; EGA's with ECD display report  8 if have only 64kb of memory
  34. ;
  35. ; Returns:
  36. ; Mono         =   0
  37. ; CGA          =   2
  38. ; PGA          =   2   (Untested, assume PGA would be treated as CGA)
  39. ; COMPAQ - CGA =  -2   to tell that user may have a single color display
  40. ; HERC         =   3   if have HERC and MSHERC.COM
  41. ; HERC         =  -3   if have HERC but w/o MSHERC.COM
  42. ; AT&T         =   4,  but only if have just CGA display, not EGA or VGA
  43. ;     Microsoft QuickC/C makes Olivetti EGA and VGA return a separate code.
  44. ;     I don't know why anyone would care if the EGA/VGA emulation were
  45. ;     good.
  46. ;
  47. ; EGA64        =   8   Because resolution limited for 64k EGA
  48. ; EGA64 w/CGA  =  -8   Because resolution limited to CGA modes
  49. ; EGA          =   9   Have minimum of 128kb of video ram
  50. ; EGA w/CGA    =  -9   Since resolution limited to CGA modes
  51. ; MCGA         =  11   If have an analog color display
  52. ; MCGA         = -11   If have an EGA ECD digital color display, since
  53. ;                      resolution of this display is limited to EGA modes
  54. ; VGA          =  13
  55. ; EGA/VGA mono =  10   I guess will catch MCGA mono too
  56. ;
  57. ; Version 0.92
  58. ;
  59. ; Tested:     CGA, HERC clone, EGA mono, EGA color, VGA color, COMPAQ CGA,
  60. ;             VGA clone, EGA clone (Paradise clone, ATI EGA Wonder), AT&T 6300
  61. ; Not tested: PGA, VGA monochrome, MCGA (color or monochrome)
  62. ;=======================================================================
  63.  
  64. DOSSEG          ;I have had problems unless this is used
  65. .model medium   ;I use QUICK C / QUICK ASM which uses MASM 5.1 simplified
  66. .code           ;directives
  67.  
  68.     public VIDEOSTAT
  69.  
  70. HERC_PORT       Equ     03bah       ; Herc display status port
  71. COMPAQ          DB     'COMPAQ'     ; BIOS ID string in COMPAQ's
  72. COMPAQ_LEN      Equ     6           ; length of string
  73.  
  74. ;Following is commented out because alternative method is faster
  75. ;ATT             DB     'OLIVETTI'   ; BIOS ID string for OLIVETTI/AT&T
  76. ;ATT_LEN         Equ     8           ; length of string
  77.  
  78. ; Please do not remove
  79. Copyright       DB    13,10,'Copyright Copr. (C) 1990 Sidney J. Kelly',13,10
  80. Copyright1      DB    'All Rights Reserved',13,10,26
  81.  
  82. EVEN
  83. VIDEOSTAT   PROC far
  84.      Push    BP                 ; save BP because old PC Video BIOS
  85.                                 ; didn't necessarily preserve this
  86.      Push    DI                 ; QBASIC requires these 2 to be saved
  87.      Push    SI
  88.                                 ; this just tests for primary display
  89. vgatest:                        ; because that is all QBASIC cares about
  90.      Mov     AX,1A00h
  91.      Mov     BX,10h             ; Test for VGA adapter
  92.      Int     10h
  93.      Cmp     AL,1Ah             ; If VGA adapter exists, it returns AL=1Ah
  94.      Jne     egatest            ; VGA does not exist so test for EGA
  95.                 ; Else VGA exists, primary display info
  96.      Cmp     BL,8               ; routine returns primary display in BL
  97.      Jne     @F
  98.      Jmp     Short  vga_color   ; VGA color exists. This does not test
  99.                                 ;  if VGA adapter clone is in emulation
  100.                                 ;  mode, such as HERC emulation
  101.                                 ;  because QBASIC does not check
  102.                                 ;  for this either.
  103. @@:
  104.      Cmp     BL,7
  105.      Jne     @f
  106.      Jmp     vga_mono           ; VGA mono exists, no effort is made to
  107.                 ; distinguish between VGA, EGA or MCGA mono
  108. @@:
  109.      Cmp     BL,11
  110.      Jne     @f
  111.      Jmp     vga_mono           ; MCGA mono exists
  112. @@:
  113.      Cmp     BL,12
  114.      Jne     @f
  115.      Jmp     Short mcga_color   ; MCGA analog color exists
  116. @@:
  117.      Cmp     BL,10
  118.      Jne     @f
  119.      Jmp     Short mcga_ecd     ; MCGA w/EGA display (untested)
  120. @@:
  121.      Cmp     BL,4               ; EGA color screen found, we have to
  122.      Jne     @f                 ; test if EGA is attached to ECD
  123.      Jmp     Short egatest      ; monitor or just plain CGA monitor
  124. @@:
  125.      Cmp     BL,5
  126.      Jne     @f
  127.      Jmp     Short vga_mono     ; EGA mono screen found
  128. @@:
  129.      Cmp     BL,2
  130.      Jne     @F
  131.      Jmp     Short att_test     ; CGA color found, test for which type
  132. @@:
  133.      Cmp     BL,1
  134.      Jne     @f
  135.      Jmp     herctest           ; MDA mono found
  136. @@:
  137.      Cmp     BL,6               ; test for PGA, treat as a CGA
  138.      Jne     @f
  139.      Jmp     cga                ; I guess this should work, untested
  140.  
  141. @@:                             ; With everything else
  142.      Jmp     unknown            ; merely assume can do normal b&w text
  143.  
  144. egatest:
  145.      Mov     AX,1200h
  146.      Mov     BX,10h
  147.      Int     10h
  148.      Cmp     BL,10h             ; EGA changes BL from 10h
  149.      Je      cgatest
  150.  
  151.      Mov     DX,BX              ; Save BX temporarily in DX
  152.      Xor     BX,BX
  153.      Mov     ES,BX
  154.      Test    ES:Byte Ptr [487h],1000b  ;EGA active?, bit 3 of 0040:0087 set?
  155.      JZ      EGA_active         ; if bit clear, then EGA is active
  156.      Jmp     Short cgatest      ; else if EGA not active (primary) check CGA
  157.  
  158. EGA_active:
  159.      Mov     BX,DX              ; get former value back from CX
  160.      Or      BH,BH              ; if BH = 1 then have MONO display
  161.      JZ      ega_color          ; else have color display
  162.      Jmp     Short vga_mono     ; treat as a VGA mono
  163.  
  164. vga_color:
  165.      Mov     AX,13              ; max screen mode is QBASIC SCREEN 13
  166.      Jmp     Quit
  167.  
  168. mcga_color:
  169.      Mov     AX,11              ; near max screen mode is QBASIC SCREEN 11
  170.      Jmp     Quit               ; MCGA can do SCREEN 13 too, but not 12.
  171.  
  172. mcga_ecd:
  173.      Mov     AX,-11             ; a warning that MCGA has EGA display
  174.      Jmp     short Quit         ; attached (Untested)
  175.  
  176. ega_color:
  177. ;*********** Based on information returned by AH 12h, BL 10h of INT 10h,
  178. ;*********** this routine reads the EGA Sense switches stored in CL
  179. ;*********** to see if really have a primary monitor that can do EGA graphics.
  180. ;*********** If do not have an ECD/multisync display, report a -9.
  181. ;*********** If have a 64kb EGA reports 8 if have ECD or -8 if have CGA
  182. ;*********** It is unclear if this will work on all clone EGA's.
  183. ;*********** It works with a VGA clone and ATI EGA Wonder as well as an
  184. ;*********** ACER EGA clone.
  185. ;*********** CL information derived from RAM memory at 0040:0088h
  186. ;***********
  187. ;*********** Source of CL information:
  188. ;*********** Ferro, "Programmer's Guide to the EGA and VGA Cards,"
  189. ;*********** (Addison-Wesley 1988), page 337.  Yet on page 473 says you can't
  190. ;*********** tell what CL will report.
  191. ;*********** Similar information hidden in Wilton, "Programmer's Guide to
  192. ;*********** PC & PS/2 Video Systems" (Microsoft 1987), page 520.
  193. ;***********
  194. ;*********** Partial information set forth in Phoenix's "System Bios for
  195. ;*********** PC/XT/AT Computers and Compatibles (Addison-Wesley 1989)
  196. ;*********** page 243 (which states t